<template>
  <div>
    <!-- 大图开始 -->
    <div class="swipe">
      <div class="swipe_img">
        <img
          src="https://yanxuan.nosdn.127.net/static-union/16653843234a47a0.png?type=webp&imageView&quality=95&thumbnail=1920x420"
          alt=""
        />
      </div>
    </div>
    <!-- 大图结束 -->

    <!-- 侧边栏开始 -->
    <aside class="left">
      <div class="body_aside_left">
        <ul>
          <li>— 热销榜 —</li>
          <li v-for="hotSale in hotSaleList" :key="hotSale.id">
            <!-- <i><img :src="gethotSale.image" alt="" /></i> -->
            <a href="" style="color: rgb(187, 51, 67); font-weight: 700"
              >{{ hotSale.test1 }}<br />{{ hotSale.test2 }}</a
            >
          </li>
        </ul>
      </div>
    </aside>
    <aside class="right">
      <div class="body_aside_code">
        <img
          src="https://yanxuan.nosdn.127.net/static-union/166020791894cf1d.png"
          alt=""
        />
      </div>
      <div class="aside_right_text">
        <p>扫码领</p>
        <p>新人APP<br />大额红包</p>
      </div>
      <div class="aside_right_subs">
        <i class="iconfont icon-dingyue"></i>
        <p>订阅电子刊</p>
      </div>
      <div class="aside_right_online">
        <i class="iconfont icon-zaixiankefu"></i>
        <p>在线客服</p>
      </div>
      <div class="aside_right_top" id="back">
        <i class="iconfont icon-huidaodingbu"></i>
        <p><a href="#">回顶部</a></p>
      </div>
    </aside>

    <!-- 新品首发开始 -->
    <div class="cube">
      <div class="cube_parent">
        <div class="top">
          <div>
            <h3>新品首发</h3>
            <span>为世间寻觅好物</span>
            <span>更多新品></span>
          </div>
        </div>
        <div class="bottom">
          <div
            v-for="newpro in newproduct"
            :key="newpro.id"
            @click="goDetail(newpro.id)"
          >
            <div class="pic">
              <img :src="newpro.image" />
            </div>
            <div class="text">
              <div>{{ newpro.title }}</div>
              <div>
                <span>￥{{ newpro.price }}</span>
                <span>￥{{ newpro.originprice }}</span>
              </div>
            </div>
          </div>
          <div class="body_right_btn">
            <i class="iconfont icon-youbian"></i>
          </div>
        </div>
      </div>
    </div>
    <!-- 新品首发结束 -->

    <!-- 人气推荐开始 -->
    <TopEell
      :Recommendlist="Recommendlist[0] || []"
      v-if="EellisShow"
      @EellisShow="EellisShow = $event"
    ></TopEell>
    <TopEell
      :Recommendlist="Recommendlist[1] || []"
      v-if="!EellisShow"
      @EellisShow="EellisShow = $event"
    ></TopEell>
    <!-- 人气推荐结束 -->

    <!-- 居家生活开始 -->
    <FamilyLife
      :Classificationlist="Classification || []"
      v-for="Classification in Classificationlist"
      :key="Classification.id"
    />
    <!-- 居家生活结束 -->

    <!-- 大家都在说 -->
    <EverybodyTalk />
  </div>
</template>

<script>
import {
  gethotSaleList,
  getnewproduct,
  getRecommendlist,
  getClassificationList,
} from "../../api/index.js";
import TopEell from "./compoent/TopEell";
import FamilyLife from "./compoent/FamilyLife";
import EverybodyTalk from "./compoent/EverybodyTalk.vue";
export default {
  name: "XHome",
  data() {
    return {
      hotSaleList: [],
      newproduct: [],
      Recommendlist: [],
      EellisShow: true,
      Classificationlist: [],
    };
  },
  methods: {
    async gethotSale() {
      this.hotSaleList = await gethotSaleList();
    },
    async getnewproduct() {
      this.newproduct = await getnewproduct();
    },
    async getRecommend() {
      this.Recommendlist = await getRecommendlist();
    },
    async getClassification() {
      this.Classificationlist = await getClassificationList();
    },
    //路由跳转
    goDetail(id) {
      this.$router.push({
        name: "detail",
        params: { id: id },
      });
    },
  },
  mounted() {
    this.gethotSale();
    this.getnewproduct();
    this.getRecommend();
    this.getClassification();
  },
  components: {
    TopEell,
    FamilyLife,
    EverybodyTalk,
  },
};
</script>

<style lang="less" scoped>
/* 大图开始 */
.swipe {
  margin-left: 150px;
  height: 420px;
  background-color: #fff;
}
.swipe .swipe_img {
  width: 1536px;
  margin: 0 auto;
  overflow-x: hidden;
}
.swipe .swipe_img img {
  width: 1920px;
  height: 420px;
}
.cube {
  // width: 100%;
  height: 431px;
  // position: fixed;
  /* background-color:lightgreen; */
  margin-top: 20px;
}
.cube .cube_parent {
  width: 1200px;
  height: 413px;
  margin: 0 auto;
  /* background-color: lightyellow; */
}
.cube .cube_parent .top {
  height: 28px;
  margin-bottom: 20px;
  margin-left: 20px;
  // background-color: lightskyblue;
  display: flex;
  justify-content: space-between;
}
.cube .cube_parent .top h3 {
  font-size: 28px;
  color: black;
  display: inline-block;
}
.cube .cube_parent .top span {
  font-size: 14px;
  line-height: 14px;
}
.cube .cube_parent .top h3:hover,
.cube .cube_parent .top span:nth-child(3):hover {
  color: #e2c199;
}
.cube .cube_parent .top span:nth-child(3) {
  margin-left: 1050px;
  position: relative;
  top: -10px;
}
.cube .cube_parent .bottom {
  height: 365px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.cube .cube_parent .bottom > div {
  width: 265px;
  height: 365px;
  margin-left: 10px;
}
.cube .cube_parent .bottom > div:hover {
  box-shadow: 0 1px 5px 1px #ccc;
}
.cube .cube_parent .bottom > div:first-child {
  margin-left: 20px;
}
.cube .cube_parent .bottom div .pic {
  height: 265px;
  /* background: url("./image/新品4.webp"); */
  background-size: 265px 265px;
}

.cube .cube_parent .bottom > div .pic:hover {
  /* background: url("./image/新品4-1.webp"); */
  background-size: 265px 265px;
}
.cube .cube_parent .bottom div .pic img {
  height: 100%;
}
.cube .cube_parent .bottom > div .text {
  height: 100px;
  /* background-color:rgb(204, 0, 255); */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.cube .cube_parent .bottom > div:hover .text {
  background-color: rgb(244, 240, 234);
}

.cube .cube_parent .bottom > div:last-child {
  width: 50px;
  height: 50px;
  border-radius: 50px;
  text-align: center;
  line-height: 50px;
  color: #fff;
  background-color: rgb(226, 193, 153);
  background-position: 0px -5658px;
  position: relative;
  top: 132.5px;
  left: 20px;
}
.cube .cube_parent .bottom > div:last-child:hover {
  background-color: #cc9756;
}
.cube .cube_parent .bottom .text span:last-child {
  text-decoration: line-through;
}
/* 大图结束 */

aside.left {
  width: 150px;
  height: 500px;
  position: sticky;
  top: 50px;
  left: -20px;
  float: left;
}
aside.right {
  width: 70px;
  height: 280px;
  position: sticky;
  top: 50px;
  right: 20px;
  float: right;
  background-color: white;
}
.body_aside_left ul {
  width: 108px;
  margin-left: 50px;
  border: 1px solid rgb(226, 222, 214);
  overflow: hidden;
  background-color: white;
}
.body_aside_left ul li:first-child {
  width: 108px;
  color: rgb(187, 51, 67);
  font-weight: 700;
  text-align: center;
  line-height: 38px;
  /* padding-top: 10px; */
  background-color: rgb(255, 252, 245);
  border-bottom: 1px solid rgb(226, 222, 214);
}
.body_aside_left ul li:last-child {
  border-bottom: none;
}
.body_aside_left ul li {
  /* text-align: center; */
  width: 86px;
  height: 38px;
  margin: auto;
  border-bottom: 1px solid rgb(226, 222, 214);
  font-size: 12px;
  font-family: "微软雅黑";
}
.body_aside_left ul li i {
  float: left;
  width: 30px;
  height: 30px;
  color: rgb(187, 51, 67);
  line-height: 38px;
  text-align: center;
  padding-right: 10px;
}
.body_aside_left ul li a {
  text-align: left;
  line-height: 12px;
  color: black;
}
.body_aside_left ul li a:hover {
  color: rgb(187, 51, 67);
}
.body_aside_code img {
  width: 70px;
  height: 70px;
  position: absolute;
  right: 0;
}
.aside_right_text {
  position: absolute;
  top: 70px;
  right: 11px;
}
.aside_right_text p:first-child {
  color: #000;
  font-size: 12px;
}
.aside_right_text p {
  color: rgb(187, 51, 67);
  text-align: center;
  font-size: 12px;
  font-family: "微软雅黑";
}
.aside_right_subs {
  position: absolute;
  top: 150px;
  color: #666666;
  /* left: 10px; */
}
.aside_right_subs,
.aside_right_online,
.aside_right_top {
  position: absolute;
  right: 0;
  margin: 0 auto;
}

.right div i {
  font-size: 28px;
  padding-left: 11px;
  margin: auto;
}
.aside_right_subs p {
  font-size: 14px;
}
.aside_right_online {
  position: absolute;
  top: 220px;
  color: #666666;
}
.aside_right_top {
  width: 70px;
  height: 70px;
  text-align: center;
  position: absolute;
  top: 280px;
  color: #666666;
  background-color: white;
  display: none;
}
.aside_right_top p a {
  color: #666666;
  text-align: center;
}
.aside_right_top:hover a,
.aside_right_subs:hover,
.aside_right_online:hover,
.aside_right_top:hover {
  color: rgb(180, 160, 120);
}

/* 居家生活 */

/* 大家都在说开始 */
.people_box {
  background-color: rgb(244, 240, 234);
  width: 1519.2px;
  height: 660px;
  margin: auto;
}
.people_box .top {
  width: 1090px;
  height: 48px;
  padding-top: 40px;
  margin: auto;
}
.people_box .top h3 {
  font-size: 28px;
  float: left;
}
.people_box .top small {
  font-size: 14px;
  display: inline-block;
  margin: 15px;
}
.people_box .bottom {
  width: 1090px;
  height: 492px;
  margin: auto;
  overflow: hidden;
  position: relative;
}
.people_box .bottom > div {
  width: 2230px;
  height: 492px;
  display: flex;
  justify-content: space-between;
  animation: swipe 10s linear infinite;
}
.people_box .bottom > div > div {
  width: 355px;
  height: 492px;
  background-color: white;
  position: relative;
  overflow: hidden;
}
.people_box .bottom > div > div img:hover {
  transform: scale(1.1);
  transition: 1s;
}
.people_box .bottom > div > div > div {
  /* float: left; */
  width: 345px;
  height: 186px;
  margin: 0 5px;
  background-color: #fff;
  position: absolute;
  bottom: 0;
}
.people_box .right_btn {
  width: 50px;
  height: 50px;
  display: block;
  border-radius: 50px;
  text-align: center;
  line-height: 50px;
  color: #fff;
  background-color: rgb(226, 193, 153);
  background-position: 0px -5658px;
  position: relative;
  top: -300px;
  left: 1340px;
}
.people_box .right_btn:hover {
  background-color: #cc9756;
}
@keyframes swipe {
  /* 开始状态 */
  0% {
    margin-left: 0px;
  }
  /* 结束状态 */
  33.3% {
    margin-left: -355px;
  }
  66.7% {
    margin-left: -710px;
  }
  100% {
    margin-left: -1065px;
  }
}
</style>
